<?php

namespace App\Services\WechatHandler;

use App\Facades\EasyWechat;

/**
 * Class Authorized.
 *
 * @author mingyoung <mingyoungcheung@gmail.com>
 */
class OpenAuthorizedHandler extends BaseEventHandler
{
    /**
     * {@inheritdoc}.
     */
    public function handle($payload = null)
    {
        //开放平台对象
        $openPlatform = EasyWechat::openPlatform($this->appid);
        //授权账号信息
        $authorizerInfo = $openPlatform->getAuthorizer($payload['AuthorizerAppid']);
        //保存授权信息
        (new \App\Services\WxMp\WxMpListService($this->appid))->openAuthorizerSave($authorizerInfo);
    }
}
